package com.origin.app.page.login

import android.content.Intent
import androidx.activity.ComponentActivity
import com.origin.app.MyApplication
import com.origin.app.R
import com.origin.app.databinding.ActivityLoginBinding
import com.origin.app.page.base.BaseActivity
import com.origin.app.page.company_list.CompanyListActivity
import com.origin.app.page.map.AppMapActivity
import com.origin.baselibrary.activity.style.ViewModelActivity
import com.origin.utils.MD5Utils
import kotlinx.coroutines.delay

class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(R.layout.activity_login) {

    companion object {
        fun launcher() {
            MyApplication.getInstance().getCurrentActivity()?.apply {
                val intent = Intent(this, LoginActivity::class.java)
                startActivity(intent)
            }
        }
    }

    override fun initContentView() {
//        contentViewBinding.etUsername.setText("zps")
        contentViewBinding.etUsername.setText("jlsjlwqz")
        contentViewBinding.etPassword.setText("Handong123!")
//        viewModel.loginAction(contentViewBinding.etUsername.text.toString(),contentViewBinding.etPassword.text.toString());
//        viewModel.todayOnHistory();
        contentViewBinding.btnLogin.setOnClickListener{
            viewModel.loginAction(contentViewBinding.etUsername.text.toString(),contentViewBinding.etPassword.text.toString());
        }

    }
    override  fun setMutableLiveDataListener(){
        viewModel.loginMutableLiveData.observe(this){
            AppMapActivity.launcher()
            finish()
        }
    }


}